<?php
/**
 * 变量操作
 *
 * Created		: 2011-06-14
 * Modified		: 2011-07-06
 * @link		: http://www.qixbo.com
 * @copyright	: [Qixbo.Com] (c) 2011
 * @version		: 0.2.0
 * @author		: Joseph Chen (jsph.chen@gmail.com)
 */
class DateTime
{

	public static function secondsFormat($seconds, $style='common')
	{
		$str = '';
		if ($seconds > 86400) {
			$days = floor($seconds/86400);
			$seconds = $seconds%86400;
		}
		if ($seconds > 3600) {
			$hours = floor($seconds/3600);
			$seconds = $seconds%3600;
		}
		if ($seconds > 60) {
			$minutes = floor($seconds/60);
			$seconds = $seconds%60;
		}

		$secondsFormats = $GLOBALS['secondsFormats'];
		if (isset($days)) {
			return sprintf(
			$secondsFormats[$style]['days_inc'],
			$days, $hours, $minutes, $seconds
			);
		} elseif (isset($hours)) {
			return sprintf(
			$secondsFormats[$style]['hours_inc'],
			$hours, $minutes, $seconds
			);
		} elseif (isset($minutes)) {
			return sprintf(
			$secondsFormats[$style]['minutes_inc'],
			$minutes, $seconds
			);
		} else {
			return sprintf(
			$secondsFormats[$style]['seconds_inc'],
			$seconds
			);
		}
	}
}
